package com.edushare.common.mailer;

import java.text.SimpleDateFormat;

import com.edushare.common.util.URLUtils;
import com.edushare.common.vo.OutgoingEmails;
import com.edushare.common.vo.Schedules;
import com.edushare.common.vo.Users;

public class SchCancel extends MailStringLoader {

	public SchCancel(Users from, Users to, Schedules sch){
		userTo = to;
		init(from, sch);
	}
	
	
	private void init(Users from, Schedules sch){
		replaceMap.put("FROM_USER_URL",URLUtils.getHomePageURL(from));
		replaceMap.put("FROM_USER_NAME",from.getCompleteUserName());
		replaceMap.put("EVENT_TITLE",sch.getSchTitle());
		replaceMap.put("START_DATE",new SimpleDateFormat("MMM d, yyyy hh:mm a").format(sch.getSchStart()));
		replaceMap.put("ENTITY_URL",URLUtils.getHomePageURL(userTo));
		
		messageString = templateParser(mailString, replaceMap);
		
	}
	
	private Users userTo = null;
	private String mailString = MailBase.get().stringMap.get(MailBase.SCHCANCEL_MAIL);
	@Override
	public OutgoingEmails send() {
		OutgoingEmails mail = new OutgoingEmails();
		mail.setContent(messageString);
		mail.setReceiverEmailId(userTo.getEmail());
		mail.setStatus(OutgoingEmails.EMAIL_TO_BE_SENT);
		mail.setCopyType(1);
		mail.setSubject("EduShare Event Cancellation Notification");
		return mail;
	}
}
